//
//  ZsNavigationController.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/4/22.
//

import UIKit

class ZsNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    

    override init(rootViewController: UIViewController) {
        super.init(rootViewController: rootViewController)
        self.setBackColor()
        self.setTitilStyle()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setTitilStyle() {
//        self.navigationBar.tintColor = UIColor.colorConvertFromString(rgbValue: 424242)
//        self.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 17),NSAttributedString.Key.foregroundColor:UIColor.colorConvertFromString(rgbValue: 424242)]
        self.navigationBar.tintColor = UIColor.init(hexString: "#424242")
        self.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 17),NSAttributedString.Key.foregroundColor:UIColor.init(hexString: "#424242")]
        UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset.init(horizontal: -600, vertical: 0), for: UIBarMetrics.default)
    }
    
    func setBackColor() {
        let rect = self.view.bounds
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context?.setFillColor(UIColor.white.cgColor)
        context?.fill(rect)
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        self.navigationBar.setBackgroundImage(image, for: UIBarMetrics.default)
        
    }

}
